package com.auto.sns.core.service.impl;

import java.util.List;
import java.util.Map;

import com.auto.sns.core.dao.SnsCoreDAOFactory;
import com.auto.sns.core.domain.SnsCoreActivity;
import com.auto.sns.core.domain.SnsCoreHyperlink;
import com.auto.sns.core.domain.SnsCoreTopic;
import com.auto.sns.core.domain.SnsCoreUserRelaMap;
import com.auto.sns.core.domain.SnsCoreVote;
import com.auto.sns.core.service.ISnsCoreInfoService;
import com.system.common.Page;
import com.system.util.BeanUtil;

public class SnsCoreInfoServiceImpl implements ISnsCoreInfoService {

	public boolean saveOrUpdateSnsCoreActivity(SnsCoreActivity snsCoreActivity)	throws Exception {
		boolean bool = true;
		try {
			if(BeanUtil.isNotBlank(snsCoreActivity.getScacGuid())){
				SnsCoreDAOFactory.snsCoreActivityDAO.updateSnsCoreActivity(snsCoreActivity);
			}else{
				SnsCoreDAOFactory.snsCoreActivityDAO.insertSnsCoreActivity(snsCoreActivity);
			}
			return bool;
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
	}

	public boolean saveOrUpdateSnsCoreHyperlink(SnsCoreHyperlink snsCoreHyperlink) throws Exception {
		boolean bool = true;
		try {
			if(BeanUtil.isNotBlank(snsCoreHyperlink.getSchyGuid())){
				SnsCoreDAOFactory.snsCoreHyperlinkDAO.updateSnsCoreHyperlink(snsCoreHyperlink);
			}else{
				SnsCoreDAOFactory.snsCoreHyperlinkDAO.insertSnsCoreHyperlink(snsCoreHyperlink);
			}
			return bool;
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
	}

	public boolean saveOrUpdateSnsCoreTopic(SnsCoreTopic snsCoreTopic) throws Exception {
		boolean bool = true;
		try {
			if(BeanUtil.isNotBlank(snsCoreTopic.getSctoGuid())){
				SnsCoreDAOFactory.snsCoreTopicDAO.updateSnsCoreTopic(snsCoreTopic);
			}else{
				SnsCoreDAOFactory.snsCoreTopicDAO.insertSnsCoreTopic(snsCoreTopic);
			}
			return bool;
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
	}

	public boolean saveOrUpdateSnsCoreVote(SnsCoreVote snsCoreVote) throws Exception {
		boolean bool = true;
		try {
			if(BeanUtil.isNotBlank(snsCoreVote.getScvoGuid())){
				SnsCoreDAOFactory.snsCoreVoteDAO.updateSnsCoreVote(snsCoreVote);
			}else{
				SnsCoreDAOFactory.snsCoreVoteDAO.insertSnsCoreVote(snsCoreVote);
			}
			return bool;
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
	}

	public boolean saveOrUpdateSnsCoreUserRelaMap(SnsCoreUserRelaMap snsCoreUserRelaMap) throws Exception {
		boolean bool = true;
		try {
			if(BeanUtil.isNotBlank(snsCoreUserRelaMap.getScurGuid())){
				SnsCoreDAOFactory.snsCoreUserRelaMapDAO.updateSnsCoreUserRelaMap(snsCoreUserRelaMap);
			}else{
				SnsCoreDAOFactory.snsCoreUserRelaMapDAO.insertSnsCoreUserRelaMap(snsCoreUserRelaMap);
			}
			return bool;
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
	}

	public List<SnsCoreActivity> queryPageListSnsCoreActivity(SnsCoreActivity snsCoreActivity, Page page) throws Exception {
		try {
			Map<String, Object> param = BeanUtil.convertBeanToMap(snsCoreActivity);
			List<SnsCoreActivity> resultList = SnsCoreDAOFactory.snsCoreActivityDAO.queryList(param, page);
			
			return resultList;
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
	}

	public List<SnsCoreHyperlink> queryPageListSnsCoreHyperlink(SnsCoreHyperlink snsCoreHyperlink, Page page) throws Exception {
		try {
			Map<String, Object> param = BeanUtil.convertBeanToMap(snsCoreHyperlink);
			List<SnsCoreHyperlink> resultList = SnsCoreDAOFactory.snsCoreHyperlinkDAO.queryList(param, page);
			
			return resultList;
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
	}

	public List<SnsCoreTopic> queryPageListSnsCoreTopic(SnsCoreTopic snsCoreTopic, Page page) throws Exception {
		try {
			Map<String, Object> param = BeanUtil.convertBeanToMap(snsCoreTopic);
			List<SnsCoreTopic> resultList = SnsCoreDAOFactory.snsCoreTopicDAO.queryList(param, page);
			
			return resultList;
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
	}

	public List<SnsCoreVote> queryPageListSnsCoreVote(SnsCoreVote snsCoreVote, Page page) throws Exception {
		try {
			Map<String, Object> param = BeanUtil.convertBeanToMap(snsCoreVote);
			List<SnsCoreVote> resultList = SnsCoreDAOFactory.snsCoreVoteDAO.queryList(param, page);
			
			return resultList;
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
	}

	public List<SnsCoreUserRelaMap> queryPageListSnsCoreUserRelaMap(SnsCoreUserRelaMap snsCoreUserRelaMap, Page page) throws Exception {
		try {
			Map<String, Object> param = BeanUtil.convertBeanToMap(snsCoreUserRelaMap);
			List<SnsCoreUserRelaMap> resultList = SnsCoreDAOFactory.snsCoreUserRelaMapDAO.queryList(param, page);
			
			return resultList;
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
	}

	public boolean updateReplyNumSnsCoreActivity(String scacGuid) throws Exception {
		boolean bool = true;
		try {
			if(BeanUtil.isNotBlank(scacGuid)){
				SnsCoreDAOFactory.snsCoreActivityDAO.updateReplyNum(scacGuid);
			}
			return bool;
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
	}

	public boolean updateRecommendNumSnsCoreActivity(String scacGuid) throws Exception {
		boolean bool = true;
		try {
			if(BeanUtil.isNotBlank(scacGuid)){
				SnsCoreDAOFactory.snsCoreActivityDAO.updateRecommendNum(scacGuid);
			}
			return bool;
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
	}

	public boolean updateFavoriteNumSnsCoreActivity(String scacGuid) throws Exception {
		boolean bool = true;
		try {
			if(BeanUtil.isNotBlank(scacGuid)){
				SnsCoreDAOFactory.snsCoreActivityDAO.updateFavoriteNum(scacGuid);
			}
			return bool;
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
	}

	public boolean updateReplyNumSnsCoreHyperlink(String schyGuid) throws Exception {
		boolean bool = true;
		try {
			if(BeanUtil.isNotBlank(schyGuid)){
				SnsCoreDAOFactory.snsCoreHyperlinkDAO.updateReplyNum(schyGuid);
			}
			return bool;
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
	}

	public boolean updateRecommendNumSnsCoreHyperlink(String schyGuid) throws Exception {
		boolean bool = true;
		try {
			if(BeanUtil.isNotBlank(schyGuid)){
				SnsCoreDAOFactory.snsCoreHyperlinkDAO.updateRecommendNum(schyGuid);
			}
			return bool;
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
	}

	public boolean updateFavoriteNumSnsCoreHyperlink(String schyGuid) throws Exception {
		boolean bool = true;
		try {
			if(BeanUtil.isNotBlank(schyGuid)){
				SnsCoreDAOFactory.snsCoreHyperlinkDAO.updateFavoriteNum(schyGuid);
			}
			return bool;
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
	}

	public boolean updateReplyNumSnsCoreTopic(String sctoGuid) throws Exception {
		boolean bool = true;
		try {
			if(BeanUtil.isNotBlank(sctoGuid)){
				SnsCoreDAOFactory.snsCoreTopicDAO.updateReplyNum(sctoGuid);
			}
			return bool;
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
	}

	public boolean updateRecommendNumSnsCoreTopic(String sctoGuid) throws Exception {
		boolean bool = true;
		try {
			if(BeanUtil.isNotBlank(sctoGuid)){
				SnsCoreDAOFactory.snsCoreTopicDAO.updateRecommendNum(sctoGuid);
			}
			return bool;
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
	}

	public boolean updateFavoriteNumSnsCoreTopic(String sctoGuid) throws Exception {
		boolean bool = true;
		try {
			if(BeanUtil.isNotBlank(sctoGuid)){
				SnsCoreDAOFactory.snsCoreTopicDAO.updateFavoriteNum(sctoGuid);
			}
			return bool;
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
	}

	public boolean updateReplyNumSnsCoreVote(String scvoGuid) throws Exception {
		boolean bool = true;
		try {
			if(BeanUtil.isNotBlank(scvoGuid)){
				SnsCoreDAOFactory.snsCoreVoteDAO.updateReplyNum(scvoGuid);
			}
			return bool;
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
	}

	public boolean updateRecommendNumSnsCoreVote(String scvoGuid) throws Exception {
		boolean bool = true;
		try {
			if(BeanUtil.isNotBlank(scvoGuid)){
				SnsCoreDAOFactory.snsCoreVoteDAO.updateRecommendNum(scvoGuid);
			}
			return bool;
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
	}

	public boolean updateFavoriteNumSnsCoreVote(String scvoGuid) throws Exception {
		boolean bool = true;
		try {
			if(BeanUtil.isNotBlank(scvoGuid)){
				SnsCoreDAOFactory.snsCoreVoteDAO.updateFavoriteNum(scvoGuid);
			}
			return bool;
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		}
	}

}
